import * as fs from 'fs';

function routeList(){
    let routers_path = __dirname + '/routes/';
    let routers = fs.readdirSync(routers_path);
    let list: any[] = [];
    routers.forEach(element => {
        let stat = fs.lstatSync(routers_path + element);
        if (!stat.isDirectory()) {
            list.push(element);
        }
    });
    let routes = list.map(file => {
        let mpath = "./routes/";
        return mpath + file.substring(0, file.lastIndexOf('.'))
    })
    return routes;
}

export default routeList;